﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cisoft.Booking.BLL;
using Cisoft.Booking.Model;

public partial class Business_Customer_CustomerAdd : WebUI.Page.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        { 
            
        }
    }

    #region 新增事件
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        int result = 0;
        string strError = "";
        string cusName = tb_CustomerName.Text;
        string cusMobile = tb_CustomerMobile.Text;

        CustomersBO cBO = new CustomersBO();
        CustomersMO cMO = new CustomersMO();

        cMO.CustomerID = cBO.GetMaxId();
        
        if (cBO.AddIsExsistCustomerName(cusName))
        {
            PageError("该员工名称已经存在！", "CustomerAdd.aspx");
        }
        else
        {
            cMO.CustomerName = cusName;
        }
        if (cBO.AddIsExsistCustomerMobile(cusMobile))
        {
            PageError("该员工手机号码已经存在！", "CustomerAdd.aspx");
        }
        else
        {
            cMO.CustomerMobile = cusMobile;
        }
        if (!Cisoft.IntegrationSystem.Common.Function.IsMobile(cusMobile))
        {
            PageError("请确认该手机是手机！", "CustomerAdd.aspx");
        }

        try
        {
            result = cBO.Add(cMO);
           
        }
        catch (Exception ex)
        {
            strError = ex.Message;
        }
        if (result > 0)
        { 
            PageRight("新增员工成功！", "CustomerManage.aspx","返回","");
        }
        else
        {
            PageError("新增失败，错误如下：" + strError, "CustomerManage.aspx");
        }
    }
    #endregion

    #region 返回事件
    protected void btn_Back_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("CustomerManage.aspx");
    }
    #endregion
}
